/*
 *  The preceding code can be added anywhere in the code, inside the init function of a
  Controller, inside the launch function of app.js, or even in a separate JavaScript file
  (recommended) where you can put all your custom Vtypes.

  The VType is a singleton class that contains a set of commonly
  used field validation functions and provides a mechanism to
  create reusable custom field validations.

  UseCase:
  vtype: 'customPass',
  msgTarget: 'side'
 */
Ext.apply(Ext.form.field.VTypes, {

    //口令密码
    customPass: function(val, field) {
        return /^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})/.test(val);
    },
    customPassText: "有效密码至少包含一个数字,一个小写字母,一个大写字母,包含一个@#$%之一的特殊字符,6~20位长度",

    //IP验证
    IPAddress: function(v) {
        return /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(v);
    },
    IPAddressText: '请输入正确的IP地址',
    IPAddressMask: /[\d\.]/i
});